mui.init();
mui.plusReady(function() {
	//	window.addEventListener('refreshdom', function(event) {
	//		console.log(event.detail.val);
	//		userindex.reqcode(event.detail.val);
	//	})
	var userindex = new Vue({
		el: "#app",
		data: {
			data: {},
			goods_id: '',
			goods: {},
			goods_images: [],
			goods_detail_images: [],
			store:{}

		},
		mounted: function() {
			var _this = this;

			_this.$nextTick(function() {
				_this.cartView();
			});

		},
		methods: {
			cartView: function() {
				var _this = this;
				var shareInfo = plus.webview.currentWebview();
				_this.goods_id = shareInfo.nid;
				
				app.postUrl(apiurl + 'Mall/goodsdetail.html', {
					goods_id: _this.goods_id
				}, function(res) {
					console.log(JSON.stringify(res))
					_this.goods = res.data.goods;
					_this.goods_images = res.data.goods_images;
					_this.goods_detail_images = res.data.goods_detail_images;
					_this.store = res.data.store;

					setTimeout(function(res) {
						var swiper = new Swiper('.swiper-container', {
							pagination: {
								el: '.swiper-pagination',
							},
							autoplay: true,
						});

					}, 200)
				});

			},
			refresh: function(done) {
				done();
			},
			infinite: function(done) {
				done();
			},
			openwin: function(urls, uid) {
				mui.openWindow({
					url: urls,
					id: uid,
					extras: {
						name: 'mui' //扩展参数
					}
				});
			},
			addcar: function(item){
				
				app.addcar(item);
				mui.toast('添加购物车成功');
			},
			carcar:function(){
				app.removeCar()
			},
			gobuy: function(){
				var _this = this;
				mui.openWindow({
					url: 'buyord.html',
					id: 'buyord',
					extras: {
						name: 'mui',
						nid: _this.goods_id,
						count: 1
					}
				});
			},
			callTel: function(){
				var _this = this;
				 plus.device.dial(_this.goods.service_tel,false);
			},
			openstore: function() {
				var _this = this;
				mui.openWindow({
					url: 'storelist.html',
					id: 'storelist',
					extras: {
						name: 'mui',
						nid: _this.store.store_id,
						title: _this.store.store_name
					}
				});
			}

		}

	});

});